package com.gqz.controller.system;

import com.gqz.domain.SysUser;
import com.gqz.dto.SysUserDto;
import com.gqz.service.ISysLoginService;
import com.gqz.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class SysLoginController {

    @Autowired
    private ISysLoginService loginService;

    @PostMapping("/login")
    public JsonResult login(@RequestBody SysUser user, HttpServletRequest request) {
        SysUserDto loginUser = loginService.login(user, request);
        return JsonResult.ok(loginUser);
    }

    @PostMapping("exit")
    public JsonResult exit(HttpServletRequest request){
        loginService.exit(request);
        return JsonResult.ok();
    }

}
